package kr.co.sdworld.stone;

import kr.co.sdworld.common.util.SpringWebContext;

import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.web.context.WebApplicationContext;

public class SpringBeanUtil
{

	public static <T> T service( Class<T> cls)
	{
		if ( cls.isAnnotationPresent( Service.class))
		{
			WebApplicationContext wac = SpringWebContext.getContext();
			return wac.getBean( cls);
		};
		
		return null;
	}
	
	public static <T> T repository( Class<T> cls)
	{
		if ( cls.isAnnotationPresent( Repository.class))
		{
			WebApplicationContext wac = SpringWebContext.getContext();
			return wac.getBean( cls);
		};
		
		return null;
	}
}
